import {defineStore} from 'pinia'
import { reqLogin } from '@/api/user'

const useUserStore = defineStore('User', {
    state:()=>{
        return {
            username:'',
            password:'',
        }
    },
    actions:{
        async login(data:any) {
            const result:any = await reqLogin(data);
            console.log("login code:"+result.code)
            console.log(result)
            if (result.code == 200) {
                return 'ok'
            }
            else {
                return Promise.reject(new Error(result.data))
            }
        } 
    },
    getters:{
    }
})

export default useUserStore;